{%extends 'layout.html'%}
{%block body%}
<link type='text/css' rel='stylesheet' href="{{url_for('static', filename='css/pagination.css') }}"/>
<script type='text/javascript' src="{{url_for('static', filename='js/jquery.form.js') }}"></script>
<script type='text/javascript' src="{{url_for('static', filename='js/jquery-ui-timepicker-addon.js') }}"></script>
<script type='text/javascript' src="{{url_for('static', filename='js/datetime.js') }}"></script>
<script type='text/javascript' src="{{url_for('static', filename='js/jquery.pagination.js') }}"></script>
<script type='text/javascript' src="{{url_for('static', filename='js/invite-dlg.js') }}"></script>
<script>
activity_id = {{activity.id}}
$(function(){
	$('form#upload-photo').ajaxForm({
    	success: function(response){
    		$('#upload-dlg').dialog('close');
    		$('img#cover').attr('src', response);    		
    	},  
	});
 	$('#invite-dlg').dialog('option', 'buttons', {'保存': function(){
 		$('#invite-dlg').dialog('close');
 	}});
    $('#save-candidates').button().click(function(){
    	$('#invite-dlg').dialog('close');
    });
    $('#edit-form').submit(function(){
    	var candidates_str = get_candidates_str();
    	$('#invite-list').attr('value', candidates_str);
    }) 		
    $('#upload-dlg').dialog({
	    	autoOpen: false,
	    	modal: true,
	    	title: '选择图片',
	    	width: 500,
	    });
	$('#open-upload').click(function(){
		$('#upload-dlg').dialog('open');	
	});
})

</script>
	<div id='invite-dlg'>
		<div id='invite-dlg-candidates'>
			
		</div>
	</div>
	<div class='left-panel'>
		<div class='top-panel'>&nbsp</div>
		<div class='mid-panel ui-widget-content'>
			<img id='cover' src='{{activity.image}}' class='act-img'/>
		</div>
		<div class='bottom-panel'>
			<p><button class='button' id='open-upload'>选择图片</button></p>
			<div id='upload-dlg'>
				<form method='post' action='/activity/uploadPhoto' enctype='multipart/form-data' id='upload-photo'>
					<input type='hidden' name='id' value='{{activity.id}}'/>
					{{csrf_token()}}
					<input type='file' class='button' name='photo'/>
					<input type='submit' value='上传' class='button' id='upload-photo'/>
				</form> 
			</div>
		</div>
	</div>
	<div class='right-panel'>
		<div class='ui-state-active top-panel caption'>{{form.title.data}}</div>
		<div class='mid-bottom-panel ui-widget-content'>			
			<form action='' method='post' id='edit-form'>
				{{form.title(class='hide')}}
				<table>
					<thead>
						<div>{{form.errors}}</div>
					</thead>
					<tbody>
						<tr>
							<th>{{form.activity_type.label}}*</th>
							<td>{{form.activity_type()}}</td>
						</tr>
						<tr>
							<th>{{form.start_time.label}}</th>
							<td>{{form.start_time(class='vDateTimeField')}}</td>
						</tr>
						<tr>
							<th>{{form.end_time.label}}</th>
							<td>{{form.end_time(class='vDateTimeField')}}</td>
						</tr>
						<tr>
							<th>{{form.activity_place.label}}</th>
							<td>{{form.activity_place()}}</td>
						</tr>
						<tr>
							<th></th>
							<td>{{form.need_approve()}}{{form.need_approve.label}}</td>
						</tr>
						<tr>
							<th></th>
							<td>{{form.allow_invitee_invite()}}{{form.allow_invitee_invite.label}}</td>
						</tr>
						<tr>
							<th></th>
							<td>{{form.is_public()}}{{form.is_public.label}}</td>
						</tr>
						<tr>
							<th></th>
							<td><input type='submit' class='button' value='提交'/> <a class='button' id='invite'>邀请</a></td>
						</tr>
					</tbody>
				</table>
				{{csrf_token()}}
				
			</form>
		</div>
	</div>
{%endblock%}
